// Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
// This source file is part of the Cangjie project, licensed under Apache-2.0
// with Runtime Library Exception.
//
// See https://cangjie-lang.cn/pages/LICENSE for license information.

#include "Actions/Comment.h"

#include <Rules/Rule.h>

namespace CangjieMigrator::Actions {

const std::string Comment::Message::OptionalChain =
    "This statement involves the '?.' syntax sugar. Cannot be processed by the tool. Please handle it manually.";
const std::string Comment::Message::VariableArgument =
    "This line of code involves variable arguments. Cannot be processed by the tool. Please handle it manually.";

Comment::Comment(PositionRange range, std::string comment, const Rules::Rule *rule)
    : range(std::move(range)), reference(rule->reference), comment(std::move(comment)), rule(rule)
{}

std::string Comment::ToString() const
{
    return range.ToString() + " " + comment;
}

std::string Comment::Generate() const
{
    if (reference.empty()) {
        return "// @CangjieMigrator " + comment;
    } else {
        return "// @CangjieMigrator[" + reference + "] " + comment;
    }
}

} // namespace CangjieMigrator::Actions
